home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
education
/
evo
/
evo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-30
|
21KB
|
721 lines
#include "INCLUDE:Lattice/math.h"
#include "INCLUDE:Lattice/stdio.h"
#include "INCLUDE:exec/types.h"
#include "INCLUDE:graphics/gfx.h"
#include "INCLUDE:graphics/gfxmacros.h"
#include "INCLUDE:exec/exec.h"
#include "INCLUDE:exec/execbase.h"
#include "INCLUDE:graphics/view.h"
#include "INCLUDE:graphics/gfxbase.h"
#include "INCLUDE:exec/libraries.h"
#include "INCLUDE:intuition/intuition.h"
#include "INCLUDE:graphics/text.h"
struct NewScreen ns;
struct NewWindow nw;
struct Screen *evo_screen;
struct Window *evo_window, *map_window, *text_window;
struct RastPort *rp, *rp2;
struct ViewPort *vp;
struct IntuiMessage *message;
struct TextAttr Ruby_Eight;
struct TextFont *fontptr;
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
struct Library *DiskfontBase;
SHORT hominid;
SHORT hominid_index[621];
int i, j, x, y, oldx, class, code, rc, color, parity;
int delta_t, delta_x, delta_y, s, fossil_index;
int point, selected_box;
BOOL button_is_down, first_pass;
UBYTE profile[ 621 ][ 52 ][ 2 ];
int SetUpEvographics(), DrawMap(), DisplayText();
#include "evo_species.include"
#include "evo_data.include"
#include "evo_africa.include"
#include "evo_text.include"
/*---------------------------------------*/
/* */
/* // Evo // */
/* */
/* A human evolution demonstration */
/* program for the Amiga */
/* */
/* Steve Bonner */
/* August 1987 */
/* */
/*---------------------------------------*/
main()
{
register int k;
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
if( (GfxBase == NULL) || (IntuitionBase == NULL)) exit();
DiskfontBase = OpenLibrary("diskfont.library",0);
if ( DiskfontBase == NULL ) exit();
SetUpEvographics();
SetDrMd( rp, JAM2 );
SetAPen( rp, 2 );
RectFill( rp, 45, 20, 295, 120 );
Move( rp, 110, 55 );
SetAPen( rp, 7 );
SetBPen( rp, 2 );
Text( rp, "(please wait)", 13 );
SetAPen( rp, 2 );
SetBPen( rp, 0 );
Move( rp, 20, 140 );
Draw( rp, 620, 140 );
for ( i = 0; i <= 20; i++) {
Move( rp, gradation[i], 138 );
Draw( rp, gradation[i], 142 ); }
Move( rp, 9, 137 );
Text( rp,
"20 10 5 4 3 2 1 ", 55 );
Move( rp, 9, 152 );
Text( rp,
" Miocene Pliocene Pleistocene", 55 );
Move( rp, 325, 45 ) ;
Text( rp, "Genus ", 12 );
Move( rp, 325, 60 ) ;
Text( rp, "Species ", 12 );
Move( rp, 325, 75 ) ;
Text( rp, "Subspecies ", 12 );
Move( rp, 325, 90 ) ;
Text( rp, "Mill yrs ago", 12 );
Move( rp, 435, 45 );
Text( rp, ":", 1 );
Move( rp, 435, 60 );
Text( rp, ":", 1 );
Move( rp, 435, 75 );
Text( rp, ":", 1 );
Move( rp, 435, 90 );
Text( rp, ":", 1 );
/* Draw the boxes to surround user options: */
for ( k = 0; k < 5; k++) {
SetAPen( rp, 3 );
RectFill( rp, 20 + k * 122, 172, 132 + k * 122, 192 );
SetAPen( rp, 6 );
Move( rp, 20 + k * 122 , 172 );
Draw( rp, 132 + k * 122 , 172 );
Draw( rp, 132 + k * 122 , 192 );
Draw( rp, 20 + k * 122 , 192 );
Draw( rp, 20 + k * 122 , 172 ); }
SetDrMd( rp, JAM1 );
Move( rp, 20, 185 );
/* Here are the various options: */
Text( rp,
" Help Text Map Glossary Notes",
61 );
SetAPen( rp, 2 );
SetDrMd( rp, JAM2 );
x = 0;
y = 1;
/* The cranium for each hominid species consists of 52 points */
/* which define its outline. Here we are copying the outlines */
/* of the nine known hominids into our working array, 'profile' */
for ( i = 0; i <= 51; i++) {
j = 2*i;
k = j+1;
profile[ 20 ][ i ][ x ] = proconsul_profile[ j ];
profile[ 20 ][ i ][ y ] = proconsul_profile[ k ];
profile[ 147 ][ i ][ x ] = kenyapith_profile[ j ];
profile[ 147 ][ i ][ y ] = kenyapith_profile[ k ];
profile[ 333 ][ i ][ x ] = afarensis_profile[ j ];
profile[ 333 ][ i ][ y ] = afarensis_profile[ k ];
profile[ 360 ][ i ][ x ] = africanus_profile[ j ];
profile[ 360 ][ i ][ y ] = africanus_profile[ k ];
profile[ 403 ][ i ][ x ] = habilis_profile [ j ];
profile[ 403 ][ i ][ y ] = habilis_profile [ k ];
profile[ 439 ][ i ][ x ] = erectus_profile [ j ];
profile[ 439 ][ i ][ y ] = erectus_profile [ k ];
profile[ 554 ][ i ][ x ] = esapiens_profile [ j ];
profile[ 554 ][ i ][ y ] = esapiens_profile [ k ];
profile[ 611 ][ i ][ x ] = neander_profile [ j ];
profile[ 611 ][ i ][ y ] = neander_profile [ k ];
profile[ 620 ][ i ][ x ] = msapiens_profile [ j ];
profile[ 620 ][ i ][ y ] = msapiens_profile [ k ]; }
/* Interpolate between known hominid forms: */
for ( i = PROCONSUL; i <= NEANDER; i++) {
delta_t = fossil_dates[i+1] - fossil_dates[i];
fossil_index = fossil_dates[i];
Forbid();
/* Now consider each point along the profile: */
for ( j = 0; j <= 51; j++ ) {
delta_x = profile[ fossil_dates[i+1] ][ j ][ x ] -
profile[ fossil_index ][ j ][ x ] ;
delta_y = profile[ fossil_dates[i+1] ][ j ][ y ] -
profile[ fossil_index ][ j ][ y ] ;
s = 1;
/* Here we do the linear interpolation. */
/* (I interpolate on the logarithmic scale, since it's easier.) */
for ( k = fossil_dates[i]+1; k < fossil_dates[i+1]; k++) {
profile[ k ][ j ][ x ] = profile[ fossil_index ][ j ][ x ] +
s * delta_x / delta_t;
profile[ k ][ j ][ y ] = profile[ fossil_index ][ j ][ y ] +
s * delta_y / delta_t;
s++;
}
} /* j */
/* Let's give our disk drive a chance to catch up: */
Permit();
} /* i */
button_is_down = FALSE;
oldx = 403;
SetAPen( rp, 1 );
WritePixel( rp, oldx, 140 );
hominid = 4;
Move( rp, 460, 45 );
Text( rp, genera[ hominid ], 18 );
Move( rp, 460, 60 );
Text( rp, species[ hominid ], 18 );
Move( rp, 460, 90 );
Text( rp, yearstring[oldx], 6 );
/* Hominid_divisions allows us to rapidly map an x-coordinate */
/* into its corresponding hominid form (an integer from 0 to 8) */
hominid = 8;
for (i = 620; i >= 20; i--) {
if ( i < hominid_divisions[ hominid ] ) hominid--;
hominid_index[i] = hominid; }
color = 8;
hominid = 4;
first_pass = TRUE;
Forbid();
while ( 1 == 1) {
if (first_pass == FALSE ) {
WaitPort( evo_window -> UserPort );
message = GetMsg( evo_window -> UserPort );
class = message -> Class;
code = message -> Code;
x = message -> MouseX;
y = message -> MouseY;
ReplyMsg( message ); }
else {
class = 0;
code = SELECTUP;
x = oldx;
y = 140;
first_pass = FALSE; }
if ( class == CLOSEWINDOW ) {
CloseWindow( evo_window );
CloseScreen( evo_screen );
exit(); }
if ( code == SELECTDOWN ) {
point = ReadPixel( rp, x, y );
/* Is our current pixel a 'user-option' color?. . . */
if ( (point == 3) || (point == 6) ) {
selected_box = (x - 10)/122;
if (selected_box == 2)
DrawMap();
else
DisplayText();
goto NoSkull; }
button_is_down = TRUE;
color = 8; }
if ( code == SELECTUP ) button_is_down = FALSE;
if ( (button_is_down) || (code == SELECTUP) ) {
if ((x >= 20) && (x <= 620)) {
SetAPen( rp, 2 );
WritePixel( rp, oldx, 140 );
SetAPen( rp, 1 );
WritePixel( rp, x, 140 );
oldx = x;
/* If the species has changed, update the labels: */
if ( hominid != hominid_index[x] ) {
hominid = hominid_index[x];
Move( rp, 460, 45 );
Text( rp, genera[ hominid ], 18 );
Move( rp, 460, 60 );
Text( rp, species[ hominid ], 18 );
Move( rp, 460, 75 );
Text( rp, subspecies[ hominid ], 18 ); }
Move( rp, 460, 90 );